package com.pureut.production.service.impl;

import com.pureut.common.datascope.annotation.DataScope;
import com.pureut.common.security.utils.SecurityUtils;
import com.pureut.production.domain.WasteTube;
import com.pureut.production.domain.dto.WasteTubeDto;
import com.pureut.production.domain.vo.WasteTubeVo;
import com.pureut.production.mapper.WasteTubeMapper;
import com.pureut.production.service.IWasteTubeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description 废料管理实现类
 * @Date 23-02-21
 * @Author hl
 **/
@Service
public class WasteTubeServiceImpl implements IWasteTubeService {

    @Resource
    private WasteTubeMapper wasteTubeMapper;


    /**
     * 查询废料管理
     */
    @Override
    @DataScope(deptAlias = "t1")
    public List<WasteTubeDto> selectWasteTubeList(WasteTubeVo wasteTubeVo) {
        return wasteTubeMapper.selectWasteTubeList(wasteTubeVo);
    }

    /**
     * 新增废料管理
     */
    @Override
    public int insertWasteTube(WasteTube wasteTube) {
        wasteTube.setDeptId(SecurityUtils.getDeptId());
        return wasteTubeMapper.insertWasteTube(wasteTube);
    }

    /**
     * 查询单个废料管理
     */
    @Override
    public WasteTubeDto selectWasteTubeById(long wasteId) {
        WasteTubeVo vo = new WasteTubeVo();
        vo.setWasteId(wasteId);
        return wasteTubeMapper.selectWasteTubeList(vo).get(0);
    }

    /**
     * 废料修正
     */
    @Override
    public int updateWasteTubeEdit(WasteTube wasteTube) {
        return wasteTubeMapper.updateWasteTubeEdit(wasteTube);
    }

    /**
     * 根据物料号码获取肥料管理数据（fegin调用）
     * @param materialNumber
     * @return
     */
    @Override
    public WasteTubeDto getWasteData(String materialNumber) {

        return wasteTubeMapper.getWasteData(materialNumber);
    }

    /**
     * 根据物料号码修改该物料入库时间（fegin调用）
     * @param wasteScrapNumber
     */
    @Override
    public void upDateInTime(String wasteScrapNumber) {
        wasteTubeMapper.upDateInTime(wasteScrapNumber);
    }

    /**
     * 根据物料号码修改该物料出库时间（fegin调用）
     * @param wasteScrapNumber
     */
    @Override
    public void upDateOutTime(String wasteScrapNumber) {
        wasteTubeMapper.upDateOutTime(wasteScrapNumber);
    }

}
